// 引入request下的axios
import axios from './request'

// get
export const get = (url,params = {}) => {
    return new Promise((resolve,reject) => {
        axios.get(url,{params}).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}
// post
export const post = (url,params = {}) => {
    return new Promise((resolve,reject) => {
        axios.post(url,params).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}
// put
export const put = (url,params = {}) => {
    return new Promise((resolve,reject) => {
        axios.put(url,params).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}
// patch
export const patch = (url,params = {}) => {
    return new Promise((resolve,reject) => {
        axios.patch(url,params).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}
// delete
export const deletes = (url,params = {}) => {
    return new Promise((resolve,reject) => {
        axios.delete(url,{params}).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}
// 删除
export const deleteAll = (url,params) => {
    return new Promise((resolve,reject) => {
        axios({
            method:'delete',
            url,
            data:params,
            headers:{
                'Content-Type':'application/json'
            }
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}